#!/usr/bin/env bash

#ip="54.242.80.150"
ip="128.8.126.92"
file=$1
#file="data/rtt_trace.full.dat"

# Get data for cwnd plot
awk -v IP=$ip 'BEGIN{last_seq = 0; last_ack = 0} {if ($3 == IP && $7 > last_seq) last_seq = $7; else
    if ($4 == IP && $8 > last_ack) last_ack = $8; to_print = last_seq - last_ack + 1; if (to_print < 1)
        to_print = 0; if(NR > 3) print $1, to_print}' $file
